/*
  学习目标：setState的第二种写法

  语法：
    setState((旧的state) => 更新的state )
*/

import React, { Component } from 'react';

export default class App extends Component {
  state = {
    count: 0,
  };

  handleClick = () => {
    this.setState((preState) => {
      return {
        count: preState.count + 1,
      };
    });

    this.setState((preState) => {
      return {
        count: preState.count + 2,
      };
    });

    this.setState((preState) => {
      return {
        count: preState.count + 3,
      };
    });
  };
  render() {
    const { count } = this.state;
    console.log('render执行几次  ----->  ');
    return (
      <div>
        <h1>{count}</h1>
        <button onClick={this.handleClick}>点我+1</button>
      </div>
    );
  }
}
